package net.dgg.zz.production.nodeOverdue.controller;

import com.alibaba.fastjson.JSONObject;
import net.dgg.framework.tac.utils.bean.DggRestResponse;
import net.dgg.framework.tac.utils.web.commmon.DggBaseController;
import net.dgg.iboss.base.service.CmsService;
import net.dgg.iboss.base.util.CustomerNumberEncryptionUtil;
import net.dgg.iboss.base.util.DesUtil;
import net.dgg.iboss.base.util.JsonUtil;
import net.dgg.iboss.base.util.datatable.DataTableUtils;
import net.dgg.iboss.base.util.datatable.domain.DataTableRequest;
import net.dgg.iboss.base.util.datatable.domain.DataTableResponse;
import net.dgg.iboss.base.util.poi.ExcelUtil;
import net.dgg.zz.production.nodeOverdue.service.ProductOrderService;
import net.dgg.tmd.foundation.platform.session.SessionManager;
import net.dgg.tmd.foundation.platform.user.entity.UserEntity;
import net.dgg.zz.common.dto.TimeoutPunishDto;
import net.dgg.zz.common.excption.CommonExcption;
import net.dgg.zz.common.utils.RegularValidUtils;
import net.dgg.zz.common.utils.StringUtils;
import net.dgg.zz.production.entity.ProductOrder;
import net.dgg.zz.production.nodeOverdue.dto.DeductionAppealDto;
import net.dgg.zz.production.nodeOverdue.service.FlscNodeOverdueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Description 节点超期扣罚申诉
 * @Author chenzaidong
 * Date
 */
@Controller
@RequestMapping("/flsc/nodeOverdue")
public class FlscNodeOverdueController extends DggBaseController {

    @Autowired
    private FlscNodeOverdueService flscNodeOverdueService;//超期扣罚
    @Autowired
    private SessionManager sessionManager;//用户管理
    @Autowired
    private DesUtil desUtil;//电话号码解码
    @Autowired
    private CmsService cmsService;//cms
    @Autowired
    private ProductOrderService productOrderService;



    /**
     * 返回节点超期扣罚记录页面
     *
     * @param model
     * @return
     */
    @RequestMapping(value = "deductionRecordHtml.html")
    public String deductionRecordHtml(Model model) {
        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未登陆！");
        model.addAttribute("user", user);
        //通过当前用户所在部门，查询对应事业部
        Map map = cmsService.findOrgParent(user.getOrgId(), "ORG_LEVEL_1");
        if(map !=null){
            model.addAttribute("orgId", map.get("id"));//当前事业部id
        }
        return "zzsc/node_overdue/deduction_record";
    }


    /**
     * 查询节点超期扣罚记录
     *
     * @param params  页面传递查询条件
     * @param request
     * @return
     */
    @RequestMapping(value = "deductionRecord.do")
    @ResponseBody
    public DataTableResponse deductionRecord(@RequestParam Map<String, Object> params, HttpServletRequest request) throws IOException {
        //设置分页参数
        DataTableRequest r = DataTableUtils.getParam(request);
        params.put("start", (r.getPage() - 1) * r.getLength());
        params.put("limit", r.getLength());

        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未登陆！");

        //查询节点超期扣罚记录
        try {
            JSONObject json = flscNodeOverdueService.selectNodeOverdueRecord(params,user);
            List<TimeoutPunishDto> list = JsonUtil.json2List(json.getString("data"), TimeoutPunishDto.class);
            List<TimeoutPunishDto> newList = new ArrayList<>();
            for(TimeoutPunishDto timeoutPunishDto: list){
                List<DeductionAppealDto> list1 = flscNodeOverdueService.getAppealByPunishId(timeoutPunishDto.getId(),null);
                if(null != list1) {
                    if (list1.size() > 0) {
                        //这里对id进行倒叙,取最新的一条数据
                        List<DeductionAppealDto> list2=list1.stream().sorted(Comparator.comparing(DeductionAppealDto::getId).reversed()).collect(Collectors.toList());
                        //申诉状态：1：申诉审核中；2：申诉驳回；3：申诉成功；4：申诉撤销
                        DeductionAppealDto deductionAppealDto = list2.get(0);
                        switch (deductionAppealDto.getState()) {
                            case 1:
                                timeoutPunishDto.setStatus("申诉审核中");
                                break;
                            case 2:
                                timeoutPunishDto.setStatus("申诉驳回");
                                break;
                            case 3:
                                timeoutPunishDto.setStatus("申诉成功");
                                break;
                            case 4:
                                timeoutPunishDto.setStatus("申诉撤销");
                                break;
                            default:
                                timeoutPunishDto.setStatus("未申诉");

                        }
                        timeoutPunishDto.setReviewerName(deductionAppealDto.getReviewerName());
                        timeoutPunishDto.setAppealId(deductionAppealDto.getId());
                    }
                }else{
                    timeoutPunishDto.setStatus("未申诉");
                }



                newList.add(timeoutPunishDto);
            }
            Integer count = json.getInteger("recordsTotal");
            return new DataTableResponse(r.getDraw(), count, count, newList, "");
        } catch (CommonExcption e) {
            throw new CommonExcption(e.getMessage());
        } catch (Exception e) {
            throw new CommonExcption("查询节点扣罚记录失败，请联系管理员");
        }
    }


    /**
     * 返回节点超期扣罚申诉页面
     *
     * @param id    扣罚记录id
     * @param appealId    申诉记录id
     * @param model
     * @return
     */
    @RequestMapping(value = "/deductionAppealHtml.html")
    public String deductionAppealHtml(Long id,Long appealId, Model model) throws IOException {
        //验证参数
        if (StringUtils.isEmpty(id)) {
            throw new CommonExcption("生产订单ID不能为空");
        }

        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未登陆！");

        try {
            flscNodeOverdueService.deductionAppealHtml(id,appealId,user,model);
        } catch (CommonExcption e) {
            throw new CommonExcption(e.getMessage());
        } catch (Exception e) {
            throw new CommonExcption("查询节点扣罚记录失败，请联系管理员");
        }
        return "zzsc/node_overdue/deduction_appeal";
    }



    /**
     * 节点超期扣罚申诉和再次进行申诉
     *
     * @param map 页面传递参数
     * @return
     */
    @RequestMapping(value = "/deductionAppeal.do")
    @ResponseBody
    public DggRestResponse deductionAppeal(@RequestParam Map<String, Object> map) {
        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未登陆！");

        //验证参数
        if (StringUtils.isEmpty(map.get("id"))) {
            return this.getFailResponse("扣罚记录ID不能为空");
        }
        if (StringUtils.isEmpty(map.get("appealId"))) {
            return this.getFailResponse("申诉记录ID不能为空");
        }
//        if (StringUtils.isEmpty(map.get("orderNo"))) {
//            return this.getFailResponse("生产订单编号不能为空");
//        }
        if (StringUtils.isEmpty(map.get("remark")) || RegularValidUtils.isSpecialCharacter(String.valueOf(map.get("remark")))) {
            return this.getFailResponse("申请原因不能为空或者有特殊字符");
        }
        if (StringUtils.isEmpty(map.get("deductionAppealReviewId"))) {
            return this.getFailResponse("审核人员不能为空");
        }

        try {
            //提交申诉
            flscNodeOverdueService.deductionAppeal(map, user);
            return this.getSuccessResponse("申诉提交成功");
        } catch (CommonExcption e) {
            throw new CommonExcption(e.getMessage());
        } catch (Exception e) {
            throw new CommonExcption("提交扣罚申诉失败，请联系管理员");
        }

    }


    /**
     * 跳转到申诉待审核页面
     *
     * @param model
     * @return
     */
    @RequestMapping(value = "appealWaitReviewHtml.html")
    public String appealWaitReviewHtml(Model model) {
        UserEntity u = sessionManager.getCurrentUser();
        Assert.notNull(u, "未获取到登录人，请重新登录！");
        model.addAttribute("user", u);
        return "zzsc/node_overdue/deduction_appeal_wait_review";
    }

    /**
     * 查询申诉待审核记录
     *
     * @param params  页面传递查询条件
     * @param request
     * @return
     */
    @RequestMapping(value = "appealWaitReview.do")
    @ResponseBody
    public DataTableResponse appealWaitReview(@RequestParam Map<String, Object> params, HttpServletRequest request) {
        //设置分页参数
        DataTableRequest r = DataTableUtils.getParam(request);
        params.put("start", (r.getPage() - 1) * r.getLength());
        params.put("limit", r.getLength());
        params.put("nodeName",params.get("nodeName1"));

        UserEntity u = sessionManager.getCurrentUser();
        Assert.notNull(u, "未获取到登录人，请重新登录！");

        try {
            DataTableResponse dataTableResponse = flscNodeOverdueService.appealWaitReview(params, u, r);
            return dataTableResponse;
        } catch (CommonExcption e) {
            throw new CommonExcption(e.getMessage());
        } catch (Exception e) {
            throw new CommonExcption("查询扣罚申诉失败，请联系管理员");
        }

    }


    /**
     * 撤回扣罚申诉
     *
     * @param id 扣罚申诉id
     * @return
     */
    @RequestMapping(value = "/withdrawAppeal.do")
    @ResponseBody
    public DggRestResponse withdrawAppeal(Long id,Long appealId) {

        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未登陆！");
        if (StringUtils.isEmpty(id)  ||  StringUtils.isEmpty(appealId) ) {
            return this.getFailResponse("未获取到申诉记录id，请刷新页面");
        }

        try {
            flscNodeOverdueService.withdrawAppeal(id,appealId, user);
            return this.getSuccessResponse("撤回扣罚申诉成功");
        } catch (CommonExcption e) {
            return this.getFailResponse(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return this.getFailResponse("撤回扣罚申诉失败，请联系管理员");
        }

    }


    /**
     * 返回申诉审核页面
     *
     * @param id    扣罚记录id
     * @param appealId    申诉记录id
     * @param model
     * @return
     */
    @RequestMapping(value = "/reviewHtml.html")
    public String reviewHtml(Long id,Long appealId, Model model) {

        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未登陆！");

        try {
            List<DeductionAppealDto> list = flscNodeOverdueService.getAppealByPunishId(id,null);
            desUtil.decryptList(new String[] {"customerPhone"}, list);
            list = CustomerNumberEncryptionUtil.encryptionList(new String[] {"customerPhone"}, list);
            //获取当前点击的申诉记录
            for (int i = 0; i < list.size(); i++) {
                DeductionAppealDto dto = list.get(i);
                if(dto.getId().equals(appealId)){
                    ProductOrder productOrder = productOrderService.getProductOrderById(dto.getScProductOrderId());
                    if(null != productOrder){
                        dto.setBusinessName(productOrder.getBusinessTypeName());
                    }
                    model.addAttribute("order", dto);//保存当前申诉记录
                    list.remove(i);//将这条记录从历史申诉记录集合中移除
                    break;
                }
            }
            model.addAttribute("recordList", list);
            return "zzsc/node_overdue/deduction_appeal_review";

        } catch (CommonExcption e) {
            throw new CommonExcption(e.getMessage());
        } catch (Exception e) {
            throw new CommonExcption("发生未知异常，请联系管理员");
        }

    }



    /**
     * 扣罚申诉审核
     *
     * @param map 页面传递参数
     *            type  1审核通过，2审核不通过
     * @return
     */
    @RequestMapping(value = "/deductionAppealReview.do")
    @ResponseBody
    public DggRestResponse deductionAppealReview(@RequestParam Map<String, Object> map) {
        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未登陆！");

        //验证参数
        String remark = String.valueOf(map.get("remark"));
        if (StringUtils.isEmpty(map.get("id"))  ||  StringUtils.isEmpty(map.get("appealId")) ) {
            return this.getFailResponse("扣罚申诉ID不能为空");
        }

        //审核驳回，备注不能为空
        if ("2".equals(map.get("type"))) {
            if (StringUtils.isEmpty(remark)) {
                return this.getFailResponse("审核说明不能为空或者有特殊字符");
            }
        }
        //审核通过如果输入备注，验证是否有特殊字符
        if (!StringUtils.isEmpty(remark) && RegularValidUtils.isSpecialCharacter(remark)) {
            return this.getFailResponse("审核说明不能有特殊字符");
        }
        //审核通过,验证扣罚金额和分数
//        if("1".equals(map.get("type"))){
//            if(!RegularValidUtils.matches("^[0-9]{1,3}(\\.[0-9]|)$", String.valueOf(map.get("deductionNumber")))){
//                return this.getFailResponse("申诉通过时，扣罚分数只能为1-3位数字，最多小数点后一位数字");
//            }
//            if(!RegularValidUtils.matches("^[0-9]{1,6}(\\.[0-9]{2}|\\.[0-9]|)$", String.valueOf(map.get("deductionMoney")))){
//                return this.getFailResponse("申诉通过时，扣罚金额只能为1-6位数字，最多小数点后两位数字");
//            }
//        }

        try {
            flscNodeOverdueService.deductionAppealReview(map,user);
            return this.getSuccessResponse("操作成功");
        } catch (CommonExcption e) {
            return this.getFailResponse(e.getMessage());
        } catch (Exception e) {
            return this.getFailResponse("扣罚申诉审核失败，请联系管理员");
        }

    }



    /**
     * 跳转到已完成申诉页面
     *
     * @param model
     * @return
     */
    @RequestMapping(value = "appealAlreadyHtml.html")
    public String appealAlreadyHtml(Model model) {
        UserEntity u = sessionManager.getCurrentUser();
        Assert.notNull(u, "未获取到登录人，请重新登录！");
        model.addAttribute("user", u);
        return "zzsc/node_overdue/deduction_appeal_already";
    }

    /**
     * 查询已完成申诉记录
     *
     * @param params  页面传递查询条件
     * @param request
     * @return
     */
    @RequestMapping(value = "appealAlready.do")
    @ResponseBody
    public DataTableResponse appealAlready(@RequestParam Map<String, Object> params, HttpServletRequest request) {
        //设置分页参数
        DataTableRequest r = DataTableUtils.getParam(request);
        params.put("start", (r.getPage() - 1) * r.getLength());
        params.put("limit", r.getLength());
        params.put("nodeName",params.get("nodeName1"));

        UserEntity u = sessionManager.getCurrentUser();
        Assert.notNull(u, "未获取到登录人，请重新登录！");

        try {
            DataTableResponse data =flscNodeOverdueService.appealAlready(params,u,r);
            return data;
        } catch (CommonExcption e) {
            throw new CommonExcption(e.getMessage());
        } catch (Exception e) {
            throw new CommonExcption("查询扣罚申诉失败，请联系管理员");
        }

    }

    /**
     * 跳转到申诉驳回页面
     *
     * @param model
     * @return
     */
    @RequestMapping(value = "appealRejectHtml.html")
    public String appealRejectHtml(Model model) {
        UserEntity u = sessionManager.getCurrentUser();
        Assert.notNull(u, "未获取到登录人，请重新登录！");
        model.addAttribute("user", u);
        return "zzsc/node_overdue/deduction_appeal_reject";
    }

    /**
     * 查询申诉驳回记录
     *
     * @param params  页面传递查询条件
     * @param request
     * @return
     */
    @RequestMapping(value = "appealReject.do")
    @ResponseBody
    public DataTableResponse appealReject(@RequestParam Map<String, Object> params, HttpServletRequest request) {
        //设置分页参数
        DataTableRequest r = DataTableUtils.getParam(request);
        params.put("start", (r.getPage() - 1) * r.getLength());
        params.put("limit", r.getLength());
        params.put("nodeName",params.get("nodeName1"));

        UserEntity u = sessionManager.getCurrentUser();
        Assert.notNull(u, "未获取到登录人，请重新登录！");

        try {
            DataTableResponse data =flscNodeOverdueService.appealReject(params,u,r);
            return data;
        } catch (CommonExcption e) {
            throw new CommonExcption(e.getMessage());
        } catch (Exception e) {
            throw new CommonExcption("查询扣罚申诉失败，请联系管理员");
        }

    }


    /**
     * 导出超期扣罚excel
     * @param params
     * @param request
     * @param response
     * @throws ParseException
     */
    @RequestMapping(value = "exportDeductionRecordExcel.do")
    @ResponseBody
    public void exportDeductionRecordExcel(@RequestParam Map<String, Object> params, HttpServletRequest request,
                                             HttpServletResponse response) throws ParseException, IOException {
        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未获取到登录人，请重新登录！");

        //查询
        JSONObject json = flscNodeOverdueService.selectNodeOverdueRecord(params,user);
        List<Map> maps = JsonUtil.json2List(json.getString("data"), Map.class);

        String fileName = "超期扣罚" + ".xls";
        String[] title = { "流程人员", "生产事业部", "订单编号", "生产单编号","工单编号","客户名称", "超期节点"
                , "超期日期", "扣罚日期", "扣罚操行分", "扣罚金额"};
        String[] key = { "flowUserName", "productOrgName", "orderNo", "productOrderNo", "workOrderNo", "customerName","noName"
                , "timeOutTime", "punishTime",  "points", "money"};
        ExcelUtil.createN(fileName, title, key, maps, response);
    }

    /**
     * 导出超期扣罚申诉待审核excel
     * @param params
     * @param request
     * @param response
     * @throws ParseException
     */
    @RequestMapping(value = "exportAppealWaitReviewExcel.do")
    @ResponseBody
    public void exportAppealWaitReviewExcel(@RequestParam Map<String, Object> params, HttpServletRequest request,
                                           HttpServletResponse response) throws ParseException, IOException {

        DataTableRequest r = DataTableUtils.getParam(request);
        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未获取到登录人，请重新登录！");

        params.put("nodeName",params.get("nodeName1"));
        //查询
        DataTableResponse dataTableResponse = flscNodeOverdueService.appealWaitReview(params, user, r);
        List data = dataTableResponse.getData();
        List<Map> maps = JsonUtil.json2List(JSONObject.toJSONString(data), Map.class);
        List<Map> maps1 = new ArrayList<>();
        for(Map map : maps){
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date(Long.valueOf(map.get("createTime").toString()));
            map.put("createTime",simpleDateFormat.format(date));
            maps1.add(map);
        }

        String fileName = "超期扣罚申诉待审核" + ".xls";
        String[] title = { "生产订单编号", "订单编号","工单编号", "合同编号", "客户", "业务类型"
                , "申诉节点", "扣罚金额", "扣罚分数","生产事业部","申诉人" ,"申诉原因", "申请时间", "当前审核人"};
        String[] key = { "scProductOrderNo", "orderNo","workOrderNo", "contractNo", "customerName",  "appealBusinessName"
                , "nodeName", "oldMoney",  "oldPoint","productOrgName","flowUserName","appealReason", "createTime"
                ,  "reviewerName"};
        ExcelUtil.createN(fileName, title, key, maps1, response);
    }


    /**
     * 导出超期扣罚申诉驳回excel
     * @param params
     * @param request
     * @param response
     * @throws ParseException
     */
    @RequestMapping(value = "exportAppealRejectExcel.do")
    @ResponseBody
    public void exportAppealRejectExcel(@RequestParam Map<String, Object> params, HttpServletRequest request,
                                            HttpServletResponse response) throws ParseException, IOException {
        DataTableRequest r = DataTableUtils.getParam(request);
        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未获取到登录人，请重新登录！");
        params.put("nodeName",params.get("nodeName1"));

        //查询
        DataTableResponse dataTableResponse =flscNodeOverdueService.appealReject(params,user,r);
        List data = dataTableResponse.getData();
        List<Map> maps = JsonUtil.json2List(JSONObject.toJSONString(data), Map.class);
        List<Map> maps1 = new ArrayList<>();
        for(Map map : maps){
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date(Long.valueOf(map.get("createTime").toString()));
            map.put("createTime",simpleDateFormat.format(date));
            maps1.add(map);
        }

        String fileName = "超期扣罚申诉驳回" + ".xls";
        String[] title = { "生产订单编号", "订单编号","工单编号", "合同编号", "客户", "申诉业务"
                , "申诉节点", "扣罚金额", "扣罚分数", "生产事业部","申诉人", "申诉原因", "申请时间", "审核人", "驳回原因"};
        String[] key = { "scProductOrderNo", "orderNo","workOrderNo", "contractNo", "customerName",  "appealBusinessName"
                , "nodeName", "oldMoney",  "oldPoint", "productOrgName", "flowUserName","appealReason", "createTime"
                ,  "reviewerName","overruleReason"};
        ExcelUtil.createN(fileName, title, key, maps1, response);
    }


    /**
     * 导出超期扣罚已完成excel
     * @param params
     * @param request
     * @param response
     * @throws ParseException
     */
    @RequestMapping(value = "exportAppealAlreadyExcel.do")
    @ResponseBody
    public void exportAppealAlreadyExcel(@RequestParam Map<String, Object> params, HttpServletRequest request,
                                        HttpServletResponse response) throws ParseException, IOException {
        DataTableRequest r = DataTableUtils.getParam(request);
        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未获取到登录人，请重新登录！");

        //查询
        DataTableResponse dataTableResponse =flscNodeOverdueService.appealAlready(params,user,r);
        List data = dataTableResponse.getData();
        List<Map> maps = JsonUtil.json2List(JSONObject.toJSONString(data), Map.class);
        List<Map> maps1 = new ArrayList<>();
        for(Map map : maps){
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date(Long.valueOf(map.get("createTime").toString()));
            Date reviewDate = new Date(Long.valueOf(map.get("reviewTime").toString()));
            map.put("createTime",simpleDateFormat.format(date));
            map.put("reviewTime",simpleDateFormat.format(reviewDate));
            maps1.add(map);
        }

        String fileName = "超期扣罚已完成申诉" + ".xls";
        String[] title = { "生产订单编号", "订单编号", "工单编号","合同编号", "客户", "申诉业务"
                , "申诉节点", "原扣罚金额", "原扣罚分数", "申诉后金额", "申诉后分数", "生产事业部","申诉人"
                , "申诉原因", "申请时间", "审核人", "审核时间"};
        String[] key = { "scProductOrderNo", "orderNo","workOrderNo", "contractNo", "customerName",  "appealBusinessName"
                , "nodeName", "oldMoney",  "oldPoint","newMoney","newPoint", "productOrgName", "flowUserName", "appealReason", "createTime"
                ,  "reviewerName","reviewTime"};
        ExcelUtil.createN(fileName, title, key, maps1, response);
    }
    @RequestMapping(value = "/reviewRecordHtml.html")
    public String reviewRecordHtml(Long id,Long appealId, Model model) {

        UserEntity user = sessionManager.getCurrentUser();
        Assert.notNull(user, "未登陆！");

        try {
            List<DeductionAppealDto> list = flscNodeOverdueService.getAppealByPunishId(id,null);
            desUtil.decryptList(new String[] {"customerPhone"}, list);
            list = CustomerNumberEncryptionUtil.encryptionList(new String[] {"customerPhone"}, list);
            //获取当前点击的申诉记录
            for (int i = 0; i < list.size(); i++) {
                DeductionAppealDto dto = list.get(i);
                if(dto.getId().equals(appealId)){
                    model.addAttribute("order", dto);//保存当前申诉记录
                    list.remove(i);//将这条记录从历史申诉记录集合中移除
                    break;
                }
            }
            model.addAttribute("recordList", list);
            return "zzsc/node_overdue/deduction_appeal_record";

        } catch (CommonExcption e) {
            throw new CommonExcption(e.getMessage());
        } catch (Exception e) {
            throw new CommonExcption("发生未知异常，请联系管理员");
        }

    }




}

